package Redis.MultilDb;

import javax.annotation.Resource;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisTestor implements ApplicationRunner
{
	
	@Resource(name = "oneRedis")
	private StringRedisTemplate oneRedis;

	@Resource(name = "twoRedis")
	private StringRedisTemplate twoRedis;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		// TODO Auto-generated method stub
		
		System.out.println("在db1中设置key的值为：hello db1");
		oneRedis.opsForValue().set("key", "hello db1");
		System.out.println("在db2中设置key的值为：hello db1");
		twoRedis.opsForValue().set("key", "hello db1");
		
		System.out.println("db1中key："+oneRedis.opsForValue().get("key"));
		System.out.println("db2中key："+twoRedis.opsForValue().get("key"));
		
	}

}
